#include "../hle.h"

typedef struct
{   
    u32 ptsMSB;
    u32 pts;
    u32 dtsMSB;
    u32 dts;
    u32 esBuffer;
    u32 auSize;
} SceMpegAu;

void sceMpegQueryStreamOffset()
{
    _log(ERR, HLE, "sceMpegQueryStreamOffset");
    RETURN(0);
}

void sceMpegQueryStreamSize()
{
    u32 bufAddr = PARAM(0);
    u32 sizeAddr = PARAM(1);

    if (mem_isOk(sizeAddr))
        mem_write32(sizeAddr, 0);

    _log(ERR, HLE, "0 = sceMpegQueryStreamSize(buf = %08x, size = %08x [0])", bufAddr, sizeAddr);
    RETURN(0);
}

void sceMpegInit()
{
    _log(ERR, HLE, "sceMpegInit()");
    RETURN(0);
}

void sceMpegFinish()
{
    _log(ERR, HLE, "sceMpegFinish");
}

void sceMpegQueryMemSize()
{
    _log(ERR, HLE, "sceMpegQueryMemSize");
    RETURN(0);
}

void sceMpegCreate()
{
    _log(ERR, HLE, "sceMpegCreate");
    RETURN(0);
}

void sceMpegDelete()
{
    _log(ERR, HLE, "sceMpegDelete");
}

void sceMpegRegistStream()
{
    _log(ERR, HLE, "sceMpegRegistStream");
    RETURN(1);
}

void sceMpegMallocAvcEsBuf()
{
    _log(ERR, HLE, "sceMpegMallocAvcEsBuf");
    RETURN(1);
}

void sceMpegQueryAtracEsSize()
{
    _log(ERR, HLE, "sceMpegQueryAtracEsSize");
    RETURN(0);
}

void sceMpegInitAu()
{
    _log(ERR, HLE, "sceMpegInitAu");
    RETURN(0);
}

void sceMpegGetAvcAu()
{
    _log(ERR, HLE, "sceMpegGetAvcAu");
    RETURN(0);
}

void sceMpegGetAtracAu()
{
    _log(ERR, HLE, "sceMpegGetAtracAu");
    RETURN(0);
}

void sceMpegAvcDecode()
{
    u32 mpegAddr = PARAM(0);
    u32 auAddr = PARAM(1);
    u32 frameWidth = PARAM(2);
    u32 bufAddr = PARAM(3);
    u32 initAddr = PARAM(4);
    SceMpegAu au;
    mem_readStruct(auAddr, &au, sizeof(SceMpegAu));
    if (mem_isOk(initAddr))
        mem_write32(initAddr, 1);
    _log(ERR, HLE, "sceMpegAvcDecode(mpeg = %08x, au = %08x, width = %d, buf = %08x, init = %08x [1])", mpegAddr, auAddr, frameWidth, bufAddr, initAddr);
    RETURN(0);
}

void sceMpegAvcDecodeMode()
{
    _log(ERR, HLE, "sceMpegAvcDecodeMode");
    RETURN(0);
}

void sceMpegAvcDecodeStop()
{
    _log(ERR, HLE, "sceMpegAvcDecodeStop");
    RETURN(0);
}

void sceMpegAvcQueryYCbCrSize()
{
    _log(ERR, HLE, "sceMpegAvcQueryYCbCrSize");
    RETURN(0);
}

void sceMpegAvcInitYCbCr()
{
    _log(ERR, HLE, "sceMpegAvcInitYCbCr");
    RETURN(0);
}

void sceMpegAtracDecode()
{
    _log(ERR, HLE, "sceMpegAtracDecode");
    RETURN(0);
}

void sceMpegRingbufferQueryMemSize()
{
    _log(ERR, HLE, "sceMpegRingbufferQueryMemSize");
    RETURN(0);
}

void sceMpegRingbufferConstruct()
{
    _log(ERR, HLE, "sceMpegRingbufferConstruct");
    RETURN(0);
}

void sceMpegRingbufferDestruct()
{
    _log(ERR, HLE, "sceMpegRingbufferDestruct");
}

void sceMpegRingbufferPut()
{
    _log(ERR, HLE, "sceMpegRingbufferPut");
    RETURN(PARAM(1));
}

u32 fakeSize = 20;

void sceMpegRingbufferAvailableSize()
{
    _log(ERR, HLE, "sceMpegRingbufferAvailableSize");
    RETURN(fakeSize > 0 ? (fakeSize--) : 0);
}

